const pattern = /String\.fromCharCode\(a\.charCodeAt\(g\)\^b\[\(b\[c\]\+b\[d\]\)%256\]\);/gm;

const hack = `String.fromCharCode(a.charCodeAt(g)^b[(b[c]+b[d])%256]);if(f.indexOf('GoJS 2.1 evaluation')>-1|| f.indexOf('(c) 1998-2021 Northwoods Software')>-1|| f.indexOf('Not for distribution or production use')>-1|| f.indexOf('gojs.net')>-1){return '';}else{return f};`;

module.exports = function(source) {
  const index = source.search(pattern);
  if (index < 0) {
    throw new Error('gojs hack failed');
  }

  return source.replace(pattern, hack);
};
